﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;

namespace WpfApp5_StackPanel.Model
{
    public class CustomTextBlock : TextBlock
    {
        // 声明依赖属性
        public static DependencyProperty TimeProperty;

        static CustomTextBlock()
        {
            FrameworkPropertyMetadata metaData = new FrameworkPropertyMetadata();
            metaData.Inherits = true;

            // 添加拥有者
            TimeProperty = Window1.TimeProperty.AddOwner(typeof(CustomTextBlock));
            // 修改元数据
            TimeProperty.OverrideMetadata(typeof(CustomTextBlock), metaData);
        }

        public CustomTextBlock() : base()
        {

        }

        #region Inherited Dependency Property declaration
        public DateTime Timer
        {
            get
            {
                return (DateTime)GetValue(TimeProperty);
            }
            set
            {
                SetValue(TimeProperty, value);
            }
        }
        #endregion
    }
}
